package com.qf.service.impl;

import com.qf.mapper.ProducterMapper;
import com.qf.mapper.ProducterTypeMapper;
import com.qf.model.ProducerType;
import com.qf.model.TProducter;
import com.qf.page.PageResult;
import com.qf.page.QueryPageBean;
import com.qf.service.ProducterService;
import com.qf.service.ProducterTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProducterTypeServiceImpl implements ProducterTypeService {
    @Autowired
    private ProducterTypeMapper producterTypeMapper;

    @Override
    public int add(ProducerType producerType) {
        return 0;
    }

    @Override
    public ProducerType findById(int id) {
        return null;
    }

    @Override
    public int edit(ProducerType producerType) {
        return 0;
    }

    @Override
    public int delete(int id) {
        return 0;
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        return null;
    }

    @Override
    public List<ProducerType> findAll() {
       return producterTypeMapper.getAllType();

    }


//    @Override
//    @Transactional
//    public int add(TProducter tProducter) {
//        device.setUpdateTime(new Date());
//        //将阈值存入redis
//        stringRedisTemplate.opsForValue().set("thresholdMax"+device.getId(),Float.toString(device.getThresholdMax()));
//        stringRedisTemplate.opsForValue().set("thresholdMin"+device.getId(),Float.toString(device.getThresholdMin()));
//
//
//        return deviceMapper.add(device);
//    }

//    @Override
//    public TProducter findById(int id) {
//        return deviceMapper.findById(id);
//    }
//
//
//    @Override
//    @Transactional
//    public int edit(TProducter tProducter) {
//        device.setUpdateTime(new Date());
//        //将阈值存入redis
//        stringRedisTemplate.opsForValue().set("thresholdMax"+device.getId(),Float.toString(device.getThresholdMax()));
//        stringRedisTemplate.opsForValue().set("thresholdMin"+device.getId(),Float.toString(device.getThresholdMin()));
//
//        int i = deviceMapper.edit(device);
//        return i;
//    }
//
//
//    @Override
//    @Transactional
//    public int delete(int id) {
//        return deviceMapper.delete(id);
//    }
//
//    @Override
//    public PageResult findPage(QueryPageBean queryPageBean) {
//        Integer CurrentPage = queryPageBean.getCurrentPage();
//        Integer PageSize = queryPageBean.getPageSize();
//        String queryString = queryPageBean.getQueryString();
//        PageResult pageResult = new PageResult();
//        List<Device> rows = deviceMapper.findPage((CurrentPage - 1) * PageSize, PageSize, queryString);
//        for (Device row : rows) {
//            Farm farm = farmMapper.findById(row.getFarmId());
//            row.setFarm(farm);
//            DeviceType deviceType = deviceTypeMapper.findById(row.getTypeId());
//            row.setDeviceType(deviceType);
//        }
//        Long total = deviceMapper.count(queryString);
//        pageResult.setRows(rows);
//        pageResult.setTotal(total);
//        return pageResult;
//    }
}
